#ifndef USERMGR_H
#define USERMGR_H
#include "singleton.h"
#include <QVector>
#include "userdata.h"
#include <QJsonArray>

class UserMgr:public Singleton<UserMgr>
{
    friend class Singleton<UserMgr>;
public:
    ~UserMgr();
    void SetName(QString name);
    void SetUid(int uid);
    void SetToken(QString token);
    QString GetIcon();
    QString GetName();
    QVector<std::shared_ptr<ApplyInfo>> GetApplyList();
    bool IsLoadConFin();
    bool AlreadyApply(int uid);//查找申请是否还在列表中
    void AddApplyList(std::shared_ptr<ApplyInfo> app);
    bool CheckFriendById(int uid);
    void AddFriend(std::shared_ptr<AuthRsp>auth_rsp);
    void AddFriend(std::shared_ptr<AuthInfo>auth_info);
    std::shared_ptr<FriendInfo> GetFriendById(int uid);
    void SetUserInfo(std::shared_ptr<UserInfo>user_info);
    int GetUid();
    void AppendApplyList(QJsonArray array);
    void AppendFriendList(QJsonArray array);
    std::shared_ptr<UserInfo> GetUserInfo();
    QVector<std::shared_ptr<FriendInfo>> GetFriendList();
    QVector<std::shared_ptr<FriendInfo>> GetChatListPerPage();
    bool IsLoadChatFin();
    void UpdateChatLoadedCount();
    QVector<std::shared_ptr<FriendInfo>> GetConListPerPage();
    void UpdateContactLoadedCount();
private:
    UserMgr();
    QString _name;
    QString _token;
    int _uid;
    std::shared_ptr<UserInfo> _user_info;
    QVector<std::shared_ptr<ApplyInfo>> _apply_list;
    QVector<std::shared_ptr<FriendInfo>> _friend_list;
    QMap<int, std::shared_ptr<FriendInfo>> _friend_map;
    int _chat_loaded;
    int _contact_loaded;
};

#endif // USERMGR_H
